#include<iostream>
#include<vector>
using namespace std;
int main(){
  long long n,m,t,min;
  cin>>n>>m;
  vector<long long> time(n,0);
  vector<vector<int>> num(n);
  for(int i=1;i<=m;i++){
    cin>>t;
    min=0;
    for(int j=0;j<n;j++){
      if(time[j]<time[min]) min=j;
    }
    time[min]+=t;
    num[min].push_back(i);
  }
  for(auto&x:num){
    if(x.empty())x.push_back(0);
    for(auto&y:x) cout<<y<<" ";
    cout<<endl;
  }
}